package com.distribute.framework.core.lang;

import java.lang.annotation.Annotation;
import java.util.HashMap;
import java.util.Map;

public class ClassField {

	String name;
	Class type;
	Map<String,Note> notes = new HashMap();
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Class getType() {
		return type;
	}
	public void setType(Class type) {
		this.type = type;
	}
	public Map<String,Note> getNotes() {
		return notes;
	}
	public void addNote(Annotation annotation) {
		notes.put(annotation.annotationType().getSimpleName(), new Note(annotation));
	}
	
	public class Note<K,V> extends HashMap<K,V>{	
		Annotation annotation;	
		public Note(Annotation annotation){
			this.annotation = annotation;
		}
		public V get(Object key){
			try {
				return (V) annotation.annotationType().getMethod(key.toString()).invoke(annotation);
			} catch (Exception e) {
				e.printStackTrace();
			}
			return null;
		}
	}
}